package com.zuxia.action;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.zuxia.entity.Car;
import com.zuxia.service.ICarService;

@Controller()
@Scope("prototype")
@ParentPackage("json-default")
@Namespace("/")
@Results({
	@Result(name="car",type="json")
})
public class CarAction extends ActionSupport implements ModelDriven<Car>{

	private Car car;
	@Override
	public Car getModel() {
		// TODO Auto-generated method stub
		return car;
	}
	@Autowired
	private ICarService carservice;
	private List<Car> list;
	public Car getCar() {
		return car;
	}
	public void setCar(Car car) {
		this.car = car;
	}
	public ICarService getCarservice() {
		return carservice;
	}
	public void setCarservice(ICarService carservice) {
		this.carservice = carservice;
	}
	public List<Car> getList() {
		return list;
	}
	public void setList(List<Car> list) {
		this.list = list;
	}
	@Action("findCar")
	public String findCar() {
		list = carservice.selectCar();
		ActionContext.getContext().getValueStack().push(list);//ѹջ
		return "car";
	}
	
}
